/**
 * created by dqn 2018/3/7
 */

package main.service.impl;

import main.entity.WebUser;
import main.repository.WebUserRepository;
import main.service.WebUserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.stereotype.Service;

@Service
public class WebUserServiceImpl implements WebUserService {
    @Autowired
    WebUserRepository webUserRepository;

    @Override
    public boolean isExistByNumber(String number) {
        return webUserRepository.getWebUserByNumber(number).isPresent();
    }

    @Override
    public WebUser getUserByPk(int pk) {
        return webUserRepository.getWebUserByPk(pk).orElse(null);
    }

    @Override
    public Page<WebUser> getAll(Pageable pageable) {
        return webUserRepository.findAll(pageable);
    }

    @Override
    public WebUser updateUser(WebUser webUser) {
        return webUserRepository.save(webUser);
    }
}
